package com.defangit.award.customization.teeth;

import com.defangit.award.domain.Award;
import com.defangit.award.domain.WinningInfo;
import com.defangit.award.extend.point.WinningInfoListener;
import laogen.lang.exception.ParameterNotValidException;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by zhangfagen on 2019/1/28.
 */
public class TeethWinningInfoListener extends WinningInfoListener {
    @Override
    public boolean beforeAttend(Award award, String openid) {
        if(award.getId()==2){
            LocalDateTime startTime= LocalDate.now().atStartOfDay();
//            List<WinningInfo> matchs=infos.parallelStream().filter(
//                    info->info.getWinTime()!=null && info.getWinTime().isAfter(startTime)
//            ).collect(Collectors.toList());
//            if(matchs.size()>1){
//                throw ParameterNotValidException.constraintNotSatisfy("抽奖次数","当日抽奖次数已用完,明日请早吧！");
//            }
        }
        return true;
    }
}
